package com.ymatou.search;

import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.ymatou.run.UiDeviceUtil;
import com.ymatou.util.Logger;

@SuppressWarnings("deprecation")
public class SearchReturnTest extends UiAutomatorTestCase{
	
	private static final String TAG = SearchReturnTest.class.getSimpleName();
	private static UiDeviceUtil uiDevice = new UiDeviceUtil();
	
	public static void testClickSearchReturn() throws UiObjectNotFoundException {
		UiSelector search_prepare_return_s = new UiSelector().resourceId("com.ymatou.shop:id/iv_search_prepare_return");
	    UiObject search_prepare_return_o = new UiObject(search_prepare_return_s);
	    
	    search_prepare_return_o.click();
	    Logger.log(TAG, "点击搜索页面的返回");
	    
	    UiSelector searchPage_hotSuggest_s = new UiSelector().textStartsWith("热门推荐");
	    UiObject searchPage_hotSuggest_o = new UiObject(searchPage_hotSuggest_s);
	    
	    //收起弹出的键盘
	    searchPage_hotSuggest_o.waitForExists(3000);
	    if (searchPage_hotSuggest_o.exists()) {
	    	uiDevice.getUiDeviceInstance().pressBack();
	    }
	}
}
